import SwiftUI

struct ForgotPasswordStep1View: View {
    @State private var phone: String = ""
    var body: some View {
        VStack(spacing: AppSpacing.xl) {
            Header(title: "找回密码", subtitle: "输入你的手机号以接收验证码")
            PhoneField(countryCode: "+86", phone: $phone)
            NavigationLink("下一步") { ForgotPasswordStep2View() }.buttonStyle(.primary)
            Spacer()
        }
        .padding(.horizontal, AppSpacing.xl)
        .padding(.top, AppSpacing.xl)
        .navigationBarTitleDisplayMode(.inline)
    }
}

struct ForgotPasswordStep2View: View {
    @State private var code: String = ""
    var body: some View {
        VStack(spacing: AppSpacing.xl) {
            Header(title: "验证码", subtitle: "输入短信验证码")
            OTPInput(code: $code)
            NavigationLink("下一步") { ForgotPasswordStep3View() }.buttonStyle(.primary)
            Spacer()
        }
        .padding(.horizontal, AppSpacing.xl)
        .padding(.top, AppSpacing.xl)
        .navigationBarTitleDisplayMode(.inline)
    }
}

struct ForgotPasswordStep3View: View {
    @State private var password: String = ""
    @State private var confirm: String = ""
    @State private var visible: Bool = false
    var body: some View {
        VStack(spacing: AppSpacing.xl) {
            Header(title: "重设密码", subtitle: "请输入新密码")
            VStack(spacing: AppSpacing.m) {
                HStack {
                    if visible { TextField("新密码", text: $password) } else { SecureField("新密码", text: $password) }
                    Button(action: { visible.toggle() }) { Image(systemName: visible ? "eye.slash" : "eye") }
                }
                .padding(.horizontal, AppSpacing.l)
                .frame(height: 52)
                .overlay(RoundedRectangle(cornerRadius: AppRadius.m).strokeBorder(.separator))
                HStack { if visible { TextField("确认新密码", text: $confirm) } else { SecureField("确认新密码", text: $confirm) } }
                    .padding(.horizontal, AppSpacing.l)
                    .frame(height: 52)
                    .overlay(RoundedRectangle(cornerRadius: AppRadius.m).strokeBorder(.separator))
            }
            Button("完成") {}.buttonStyle(.primary)
            Spacer()
        }
        .padding(.horizontal, AppSpacing.xl)
        .padding(.top, AppSpacing.xl)
        .navigationBarTitleDisplayMode(.inline)
    }
}


